package me.sunpeng.interrupt;

/**
 * @author sp
 */
public class InterruptDemo4 {
    public static void main(String[] args) {
        //测试当前线程是否被中断（检查中断标志），返回一个boolean并清楚中断状态
        //第二次再调用时中断状态已经被清楚，并返回一个false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//false
        System.out.println("----1");
        Thread.currentThread().interrupt();//中断标志位设置位true
        System.out.println("----2");
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//true
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//false


    }
}
